import { createSlice } from "@reduxjs/toolkit";
const counterSlice = createSlice({
  name: "counter",
  initialState: {
    from: "北京",
    to: "上海",
  },
  reducers: {
    usecity(state, actions) {
      if (actions.payload.type == "to") {
        state.to = actions.payload.city;
      } else {
        state.from = actions.payload.city;
      }
    },
  },
});
export default counterSlice.reducer;
export const { usecity } = counterSlice.actions;
